<?php
/*
 * Modificacion: Miguel Angel Vargas Cabezas
 * Fecha:   2010-12-02
 * descripcion: Se adapta a la nueva metodologia de Creacion de Items
*/        define("GRID_SOURCE", "");
        include(GRID_SOURCE."class/gridclasses.php"); //Include the grid engine.

        session_start();

        $id=$_REQUEST['id'];
        $id = explode("10000001",$id);

        $transaccion = $id[0];
        $secuencia   = $id[1];

        require_once "../funciones.php";
        $link_caweb = con_caweb();

        $grid_id = array("grid");
        unset($_SESSION["grid"]);
        include(GRID_SOURCE."class/gridcreate.php"); //Creates grid objects.
?>
<html>
        <head>
                <title>Despiece</title>
                <script language="Javascript" type="text/javascript" src="<?php print(GRID_SOURCE);?>javascript/javascript.js"></script>
                <link rel="stylesheet" type="text/css" media="screen" href="../css/caweb.css" />
                <link href="<?php print(GRID_SOURCE);?>css/style.css" rel="stylesheet" type="text/css" />
				<script type='text/javascript' src="<?php print(GRID_SOURCE);?>server.php?client=all"></script>
				<script type='text/javascript'>
				HTML_AJAX.defaultServerUrl = '<?php print(GRID_SOURCE);?>server.php';
                                function valida(){
                                    if($("#marca").val() == ""){
                                        alert("La marca es Obligatoria");
                                        $("#marca").focus();
                                        return false;
                                    }
                                    else if($("#modelo").val() == ""){
                                        alert("El modelo es obligatorio");
                                        $("#modelo").focus();
                                        return false;
                                    }
                                    else return true;
                                }
				</script>
                <script src="../js/jquery.js" type="text/javascript"></script>
                <script src="../js/caweb.js" type="text/javascript"></script>
        </head>
        <body>

        <?
        $result1 ="SELECT * FROM temporal_oc WHERE transaccion='$transaccion' AND secuencia='$secuencia' ";
        $result1=mysql_query($result1,$link_caweb) or die('Error temporal_oc, '.mysql_error());
        $row1 = mysql_fetch_array($result1);
        ?>
        <font size="4">Despiece del Item: <? echo $row1[item]; ?> </font>
        <br />

        <form name="despiece" method="POST" action="despiece2.php" onsubmit="return valida()">
            <table>
                <tr>
                    <td>
                        <label for="marca">Marca</label>
                    </td>
                    <td>
                        <input type="text" name="marca" id="marca"/>
                    </td>
                    <td>
                        <label for="modelo">Modelo</label>
                    </td>
                    <td>
                        <input type="text" name="modelo" id="modelo" />
                    </td>
                </tr>
            </table>
        <table>
            <tr>
                <td>
                    <div><label for="clasetx">Clase</label>
                        <select name="clase" id="clasetx" class="mayusculas" onchange="$('#guardar').attr('disabled',''); funcion_subclases(this.value,2);">
                        <option value='' SELECTED>Seleccionar..</option>
                        <?php
                            $link_intranetpccom = con_intranetpccom();
                            $sql ="select cla.codigoclase,cla.descripcion from taxonomia tax
                                    inner join clases cla on tax.codigoclase = cla.codigoclase and cla.estado = 1
                                    where tax.despiece = 'Si' and tax.estado = 1
                                    group by codigoclase order by cla.descripcion";
                            $result64=mysql_query($sql,$link_intranetpccom) or die('Error Clase, '.mysql_error().$sql);
                            while($row64 = mysql_fetch_array($result64)){
                                echo "<option value='{$row64['codigoclase']}'>{$row64['descripcion']}</option>";
                            }
                        ?>
                    </select>
                    </div>
                </td>
                <td>
                    <div id="layer2_subclases"></div>
                </td>
                <td>
                    <div id="layer2_familias"></div>
                </td>
                <td>
                    <div id="layer2_grupos"></div>
                </td>
            </tr>
                <td colspan="5">
                    <label for="valor">Valor :</label>
                    <input type="text" id="valor" size="10" name="valor" value="" />
                    <input type="hidden" name="codigosubclase" id="codigosubclase" />
                    <input type="hidden" name="transaccion" id="transaccion" value="<? echo $transaccion; ?>" />
                    <input type="hidden" name="secuencia" id="secuencia"  value="<? echo $secuencia; ?>" />
                    <input type="hidden" name="item" id="item"  value="<? echo $row1['item']; ?>" />
                    <input name="guardar" id="guardar" type="submit" value="Adicionar" disabled="disabled"/>
                </td>
        </table>
        <center><input type="button" value="Terminar Despiece" onclick="window.close();"/></center>
    </form>

        <?php
        $link_caweb = con_caweb();
            $condicion="transaccion='$transaccion' AND secuencia='$secuencia' ";
   			$_SESSION["grid"]->SetDatabaseConnection($_SESSION['caweb']['basededatos'], "caweb", "caweb");
           	$_SESSION["grid"]->SetSqlSelect('id, transaccion,secuencia,item,item2,valor,alias,marca,modelo', 'temporal2_oc',$condicion);
			$_SESSION["grid"]->SetUniqueDatabaseColumn("id", false);
			$_SESSION["grid"]->SetTitleName(" Transaccion: $transaccion - Secuencia: $secuencia");
			$_SESSION["grid"]->SetEditModeEdit(true);
            $_SESSION["grid"]->SetEditModeDelete(true);
			$_SESSION["grid"]->SetMaxRowsEachPage(12);
            $_SESSION["grid"]->SetDatabaseColumnEditable("id", false);
			$_SESSION["grid"]->SetDatabaseColumnEditable("transaccion", false);
   	        $_SESSION["grid"]->SetDatabaseColumnEditable("secuencia", false);
            $_SESSION["grid"]->SetDatabaseColumnEditable("item", false);
            $_SESSION["grid"]->SetDatabaseColumnEditable("item2", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("valor", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("alias", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("marca", true);
            $_SESSION["grid"]->SetDatabaseColumnEditable("modelo", true);
			$_SESSION["grid"]->SetShowExcelIco(false);
			$_SESSION["grid"]->SetShowPrintIco(true);
			$_SESSION["grid"]->PrintGrid(MODE_EDIT);
        ?>
        
        </body>
</html>